package cn.edu.lingnan.servlet;

import java.io.IOException;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.lingnan.dao.MemberDAO;
import cn.edu.lingnan.dao.UserDAO;
import cn.edu.lingnan.dto.Member;



public class joinCorporationServlet extends HttpServlet 
{
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		String mNo=req.getParameter("uId");
		String mId=req.getParameter("cId");
		UserDAO u=new UserDAO();
		String mName=u.findUseruName(mNo);
		System.out.println(mName);
		String mPass="N";
		int mTag=0;
		Member m=new Member();
		m.setmNo(mNo);
		m.setmName(mName);
		m.setmId(mId);
		m.setmPass(mPass);
		m.setmTag(mTag);

		MemberDAO me=new MemberDAO();		
		int flag=me.insertInfoToMember(m);
		Vector<Member> v=me.findAllMember();
		HttpSession s=req.getSession();
		s.setAttribute("allMember", v);
		
		if(flag==1)
			resp.sendRedirect(req.getContextPath()+"/pass.jsp");
		else
			resp.sendRedirect(req.getContextPath()+"/error.html");
	}
}
